
<?php 
global $connect;
$query = "SELECT cat.nomcategorie AS 'CATEGORIE',prd.nproduit AS NPRODUIT,  prd.marque AS 'MARQUE',em.cellule, em.quantite, em.maxi  FROM produits prd
    LEFT JOIN categories cat ON (cat.ncategorie = prd.ncategorie)
    LEFT JOIN emplacements em ON (prd.nproduit = em.nproduit)
  WHERE em.nmagasin = '".$_GET['show_mag_id']."' ORDER BY cat.nomcategorie;";

$mag = mysql_query($query) or die(mysql_error());

?>
<h1>Liste des produits en commande</h1><br />
	<form method="post" action="index.php?page=magasins&action=valid_cmd">
	<table frame="border" border="1" cellspacing="0">
		<thead>
			<tr> <th>Marque</th> <th>Categories</th> <th>Cellule</th> <th>Quantite</th> <th>Maximum</th><th>Cmd</th> </tr>		</thead>
		<tbody>
		<?php
			while ($data = mysql_fetch_array($mag))
			{
				$nbr = $data['maxi'] - $data['quantite'];
				echo "<tr > <td align='center' width='120px'><a href='index.php?page=magasins&show_mag_id=".$_GET['show_mag_id']."'>".$data['MARQUE']." </a></td>";
				echo "<td align='center' width='120px'>".$data['CATEGORIE']." </td>";
				echo "<td align='center' width='120px'>".$data['cellule']." </td>";
				echo "<td align='center' width='120px'>".$data['quantite']." </td>";
				echo "<td align='center' width='120px'>".$data['maxi']."</td>";
				echo "<td align='center' width='120px'><input name='".$data['NPRODUIT']."' type='text' style='width:20px;border: solid #ddd 1px' value='".$nbr."'></td></tr>";			
			}
		?>
			<tr>
				<td colspan='6' align='right'>
					Fournisseur : <select name="fournisseur" style="width:154px">
					<?php
						$query = "SELECT * FROM fournisseurs";
						$four = mysql_query($query) or die(mysql_error());
						while ($data = mysql_fetch_array($four))
						{
							echo "<option value='".$data['NOM']."'>".$data['NOM']."</option>";
						}
					?>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan='6' align='right'>Date Livraison : <input type="text" style="text-align:center;width:150px" name="date" value="<?php echo date('d/m/Y')?>"></td>
			</tr>
			<tr>
				<td colspan='6' align='right'><input type="submit" value="Valider Commande"></td>
			</tr>
		</tbody>
	</table>
	<input type="hidden" name="idmag" value="<?php echo $_GET['show_mag_id'];?>" />
	</form>
	<br />
	<center><h3><a href="index.php?page=magasins&action=livraison&id_mag=<?php echo $_GET['show_mag_id'] ?>">Livraison en cours sur ce magasin</a></h3></center>
	<center><h1><a href="index.php?page=magasins&action=magasin&show_mag_id=<?php echo $_GET['show_mag_id'] ?>"><img width="30px" height="30px" src="./img/jamembo-back.png" />Retour</a></h1></center>
